/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author sflesca
 */
@Entity
@Table(name = "coupon")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Coupon.findAll", query = "SELECT c FROM Coupon c"),
    @NamedQuery(name = "Coupon.findByIdCoupon", query = "SELECT c FROM Coupon c WHERE c.idCoupon = :idCoupon"),
    @NamedQuery(name = "Coupon.findByScadenza", query = "SELECT c FROM Coupon c WHERE c.scadenza = :scadenza")})
public class Coupon implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idCoupon")
    private Integer idCoupon;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Scadenza")
    @Temporal(TemporalType.TIMESTAMP)
    private Date scadenza;
    @JoinColumn(name = "cliente_ID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Cliente clienteID;

    public Coupon() {
    }

    public Coupon(Integer idCoupon) {
        this.idCoupon = idCoupon;
    }

    public Coupon(Integer idCoupon, Date scadenza) {
        this.idCoupon = idCoupon;
        this.scadenza = scadenza;
    }

    public Integer getIdCoupon() {
        return idCoupon;
    }

    public void setIdCoupon(Integer idCoupon) {
        this.idCoupon = idCoupon;
    }

    public Date getScadenza() {
        return scadenza;
    }

    public void setScadenza(Date scadenza) {
        this.scadenza = scadenza;
    }

    public Cliente getClienteID() {
        return clienteID;
    }

    public void setClienteID(Cliente clienteID) {
        this.clienteID = clienteID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCoupon != null ? idCoupon.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Coupon)) {
            return false;
        }
        Coupon other = (Coupon) object;
        if ((this.idCoupon == null && other.idCoupon != null) || (this.idCoupon != null && !this.idCoupon.equals(other.idCoupon))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Coupon[ idCoupon=" + idCoupon + " ]";
    }
    
}
